package com.shop2cn.iapi.coupon.parameter;

import java.util.ArrayList;
import java.util.List;

public class ShoppingInfo {
    /**
     * / 买家信息
     */
    public BuyerInfo BuyerInfo;
    /**
     * / 买手订单信息
     */
    public List<SellerOrderInfo> SellerOrderInfos;
    /**
     * / 使用平台优惠券编号
     */
    public String PlatformCouponCode;
    /**
     * / 使用平台
     */
    public int PlatformUsage;
    /**
     * / 是否使用团长券 默认false:不使用  ，true:使用
     */
    public boolean CanUseGroupCoupon=false;

    public BuyerInfo getBuyerInfo() {
        return BuyerInfo;
    }

    public void setBuyerInfo(BuyerInfo buyerInfo) {
        BuyerInfo = buyerInfo;
    }

    public List<SellerOrderInfo> getSellerOrderInfos() {
        return SellerOrderInfos;
    }

    public void setSellerOrderInfos(List<SellerOrderInfo> sellerOrderInfos) {
        SellerOrderInfos = sellerOrderInfos;
    }

    public String getPlatformCouponCode() {
        return PlatformCouponCode;
    }

    public void setPlatformCouponCode(String platformCouponCode) {
        PlatformCouponCode = platformCouponCode;
    }

    public int getPlatformUsage() {
        return PlatformUsage;
    }

    public void setPlatformUsage(int platformUsage) {
        PlatformUsage = platformUsage;
    }

    
    public boolean getCanUseGroupCoupon() {
        return CanUseGroupCoupon;
    }
    public void setCanUseGroupCoupon(boolean canUseGroupCoupon) {
    	CanUseGroupCoupon = canUseGroupCoupon;
    }
    public List<ProductInfo> getAllProducts()
    {
        List<ProductInfo> productInfos = new ArrayList<ProductInfo>();
        for (SellerOrderInfo sellerOrderInfo : SellerOrderInfos) {
            List<OrderInfo> orderInfos = sellerOrderInfo.getOrderInfos();

            for (OrderInfo orderInfo : orderInfos) {
                List<ProductInfo> productInfosList = orderInfo.getProductInfos();

                for (ProductInfo productInfo : productInfosList) {
                    productInfos.add(productInfo);
                }
            }
        }

        return productInfos;
    }

    public List<ProductInfo> getProductsByCouponCode(String couponCode)
    {
        List<ProductInfo> productInfos = new ArrayList<ProductInfo>();
        for (SellerOrderInfo sellerOrderInfo : SellerOrderInfos) {

            if (sellerOrderInfo.getCouponCode() != null && sellerOrderInfo.getCouponCode().equals(couponCode))
            {
                List<OrderInfo> orderInfos = sellerOrderInfo.getOrderInfos();

                for (OrderInfo orderInfo : orderInfos) {
                    List<ProductInfo> productInfosList = orderInfo.getProductInfos();

                    for (ProductInfo productInfo : productInfosList) {
                        productInfos.add(productInfo);
                    }
                }
            }
        }

        return productInfos;
    }
    
	/**
	 * 业务平台来源，用于隔离普通业务平台与分销业务平台
	 */
    private int platformSource;
    public int getPlatformSource() {
        return platformSource;
    }

    public void setPlatformSource(int platformSource) {
        this.platformSource = platformSource;
    }
}
